package com.itheima.java.ai.langchin4j.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("vital_signs")
public class VitalSigns {
    @TableId(type = IdType.AUTO)
    private Long id;
    
    private Long userId;
    
    private BigDecimal height;
    
    private BigDecimal weight;
    
    private Integer systolicBp;
    
    private Integer diastolicBp;
    
    private BigDecimal bloodSugar;
    
    private Integer heartRate;  // 添加心率字段
    
    private LocalDateTime recordTime;
    
    // 以下方法提供额外功能，不与@Data冲突
    
    public Double getTemperature() {
        return 36.5; // 默认体温
    }
    
    public Integer getRespiratoryRate() {
        return 20; // 默认呼吸频率
    }
    
    public Double getOxygenSaturation() {
        return 98.0; // 默认血氧饱和度
    }
    
    public Double getBloodGlucose() {
        return this.bloodSugar != null ? this.bloodSugar.doubleValue() : null;
    }
    
    public Double getWeight() {
        return this.weight != null ? this.weight.doubleValue() : null;
    }
    
    public Double getHeight() {
        return this.height != null ? this.height.doubleValue() : null;
    }
    
    public Double getBmi() {
        if (this.height != null && this.weight != null && this.height.doubleValue() > 0) {
            double h = this.height.doubleValue() / 100; // 转换为米
            return this.weight.doubleValue() / (h * h);
        }
        return null;
    }
    

    
    public String getDataSource() {
        return "manual"; // 默认数据源
    }
    
    public String getNotes() {
        return ""; // 默认备注
    }
    

}